package com.j48.entrancegurad.service.impl;

import com.j48.entrancegurad.mapper.UserMapper;
import com.j48.entrancegurad.model.User;
import com.j48.entrancegurad.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserService implements IUserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 按id查询用户
     * @param user
     * @return
     */
    @Override
    public User selectByUser_id(User user) {
        return  userMapper.selectById(user);
    }

    /**
     * 按姓名查询用户
     * @param user
     * @return
     */
    @Override
    public List<User> selectByUser_name(User user) {
        return  userMapper.selectByName(user);
    }

    /**
     * 查询所有用户
     * @return
     */
    @Override
    public ArrayList<User> selectAll() {
        return userMapper.selectAll();
    }

    /**
     * 按名字查询用户
     * @param user
     * @return
     */
    @Override
    public ArrayList<User> selectByName(User user) {
        return userMapper.selectByName1(user);
    }

    /**
     * 按业主查询用户
     * @param user
     * @return
     */
    @Override
    public ArrayList<User> selectByHostId(User user) {
        return userMapper.selectByHostId(user);
    }

    /**
     * 添加用户
     * @param user
     * @return
     */
    @Override
    public int insertUser(User user) {
        return userMapper.insert(user);
    }

    /**
     * 按用户姓名和openid查询用户
     * @param user
     * @return
     */
    @Override
    public ArrayList<User> selectByNameAndOpen(User user) {
        return userMapper.selectByName2(user);
    }

    /**
     * 按openid查询用户
     * @param user
     * @return
     */
    @Override
    public User selectByToken(User user) {
        return userMapper.selectByToken(user);
    }


}
